<?php if ( ! defined('BASEPATH')) exit('No direct script access allowed');
class Strategy extends Front_Controller
{
	public static $m_arrTpl = array('strategy'=>'0','nous'=>'1','ask'=>'2');
	//public static $m_arrTitle  = array('0'=>'温泉攻略','1'=>'温泉常识','2'=>'温泉问答');
	function __construct()
	{
		parent::__construct();
		$this->load->helper(array('form'));
		$this->load->model('front/Strategy_mdl');
		
		$this->load->helper(array('form'));
		$this->load->model('front/Frontget_ml');
		$this->load->model('front/Search_m');		
		$this->load->model('front/News_cate_m');
		$this->siteSetings=$this->Frontget_ml->get_site_settings();	//??????????
		$this->announcement=$this->Frontget_ml->get_announcement();	//??????????		
		$this->lineclass=$this->Frontget_ml->get_lineclass();//?????·????
		$this->TicketClass=$this->Frontget_ml->getTicketClass();//????????
		$this->newsclass=$this->Frontget_ml->get_newsclass();//????????
		$this->tagsclass=$this->Frontget_ml->get_tagsclass();//获取攻略分类
		$this->des_tags=$this->Search_m->get_des_tags();	//??????????	
		$this->StrategyClass=$this->Strategy_mdl->getStrategyClass();	//获取攻略分类	
		$this->model=13;			//攻略model为13
		$current_title     = $this->siteSetings["site_description"];
		$this->m_arrPublic =   array("newsclass"=>$this->newsclass,"TicketClass"=>$this->TicketClass,"lineclass"=>$this->lineclass,"des_tags"=>$this->des_tags,"current_title"=>$current_title,"siteSetings"=>$this->siteSetings,"tagsclass"=>$this->tagsclass);
	}
	
	
	public function strategyList($p_sort = 'strategy')
	{
		$this->load->library('pagination');
		$config['base_url'] = site_url('/hotel/strategy_list/');
		$type=0	;
		$total_rows= $this->Strategy_mdl->getAllStrategy(0,10,0,self::$m_arrTpl[$p_sort]);
		$config['total_rows']     = $total_rows;
		$config['per_page']       = 10;
		$config['uri_segment']    = 4;
		$config['full_tag_open']  = '';
		$config['full_tag_close'] = '';
		$config['cur_tag_open']   = '&nbsp;<span class="current">';
		$config['cur_tag_close']  = '</span>';
		$config['prev_link']      = '上一页';
		$config['next_link']      = '下一页';
		$config['first_link']     = ' 首页';
		$config['last_link']      = ' 尾页';
		$this->pagination->initialize($config);
		$begin_record             = $this->uri->segment(4);
		$type                     = 1;
		$arr['strategy']          = $this->Strategy_mdl->getAllStrategy($begin_record,$config['per_page'],$type,self::$m_arrTpl[$p_sort]);	
		// 分页END
		$data  = $arr + $this->m_arrPublic;
		$data['title'] =$this->StrategyClass['classname'][self::$m_arrTpl[$p_sort]];
		$this->load->view('strategy_list',$data);
	}
	
	public function singeStrategy($p_id)
	{
		$arr = $this->Strategy_mdl->getStrategy($p_id);
		$nextId = $this->Strategy_mdl->getNextStrategyIdById($p_id);
		$arrNext['next'] = $this->Strategy_mdl->getStrategy($nextId);
		if (empty($arrNext['next']))
		{
			$arrNext['next'] = array('id' => 0,'strategy_title' => '');
		}
		$data = $arr + $this->m_arrPublic + $arrNext;
		$data['model'] = $this->model;
		$this->load->view('strategy_show',$data);
	}
	
	public function index($p_index)
	{
		$this->load->library('pagination');
		$config['base_url'] = site_url('/hotel/strategy_list/');
		$type=0	;
		$total_rows= $this->Strategy_mdl->getAllStrategy(0,10,0,$p_index);
		$config['total_rows']     =$total_rows;
		$config['per_page']       = 10;
		$config['uri_segment']    = 4;
		$config['full_tag_open']  = '';
		$config['full_tag_close'] = '';
		$config['cur_tag_open']   = '&nbsp;<span class="current">';
		$config['cur_tag_close']  = '</span>';
		$config['prev_link']      = '上一页';
		$config['next_link']      = '下一页';
		$config['first_link']     = ' 首页';
		$config['last_link']      = ' 尾页';
		$this->pagination->initialize($config);
		$begin_record             = $this->uri->segment(4);
		$type                     = 1;
		$arr['strategy']          = $this->Strategy_mdl->getAllStrategy($begin_record,$config['per_page'],$type,$p_index);	
		// 分页END
		$data  = $arr + $this->m_arrPublic;
		
		$data['title'] = $this->StrategyClass['classname'][$p_index];
		$data['TopNewsList'] =$this->News_cate_m->getTopNewsList();							//热门资讯
		$this->load->view('strategy_list',$data);
	}

}
